One file per plot
shps<-list.files("/Users/ben/Dropbox/Weecology/ECODSEdataset/Task1/ITC/",pattern=".shp",full.names = T)
itcs<-lapply(shps,readShapePoly)
names(itcs)<-sapply(itcs,function(x){
id<-unique(x$Plot_ID)
})
print(names(itcs))
## [1] "OSBS_001" "OSBS_003" "OSBS_006" "OSBS_007" "OSBS_008" "OSBS_009"
## [7] "OSBS_010" "OSBS_011" "OSBS_014" "OSBS_015" "OSBS_016" "OSBS_017"
## [13] "OSBS_018" "OSBS_019" "OSBS_025" "OSBS_026" "OSBS_029" "OSBS_030"
## [19] "OSBS_032" "OSBS_033" "OSBS_034" "OSBS_035" "OSBS_036" "OSBS_037"
## [25] "OSBS_038" "OSBS_042" "OSBS_043" "OSBS_044" "OSBS_048" "OSBS_051"
chms<-list.files("/Users/ben/Dropbox/Weecology/ECODSEdataset/RSdata/chm/",pattern=".tif$",full.names = T)
chms<-lapply(chms,raster)
#name the plotids
names(chms)<-sapply(chms,function(x){
id<-names(x)
str_match(id,"(\\w+)_chm")[,2]
})
print(names(chms))
## [1] "OSBS_001" "OSBS_002" "OSBS_003" "OSBS_004" "OSBS_005" "OSBS_006"
## [7] "OSBS_007" "OSBS_008" "OSBS_009" "OSBS_010" "OSBS_011" "OSBS_013"
## [13] "OSBS_014" "OSBS_015" "OSBS_016" "OSBS_017" "OSBS_018" "OSBS_019"
## [19] "OSBS_020" "OSBS_021" "OSBS_025" "OSBS_026" "OSBS_027" "OSBS_028"
## [25] "OSBS_029" "OSBS_030" "OSBS_031" "OSBS_032" "OSBS_033" "OSBS_034"
## [31] "OSBS_035" "OSBS_036" "OSBS_037" "OSBS_038" "OSBS_039" "OSBS_040"
## [37] "OSBS_041" "OSBS_042" "OSBS_043" "OSBS_044" "OSBS_048" "OSBS_050"
## [43] "OSBS_051"
Let’s view a few tree crowns for plots. Only plot if we have matching names.
for(x in names(chms)){
if(!is.null(itcs[[x]])){
plot(chms[[x]])
plot(itcs[[x]],add=T)
title(x)
}
}
rgb<-list.files("/Users/ben/Dropbox/Weecology/ECODSEdataset/RSdata/camera/",pattern=".tif$",full.names = T)
rgb<-lapply(rgb,stack)
#name the plotids
names(rgb)<-sapply(rgb,function(x){
id<-names(x[[1]])
str_match(id,"(\\w+)_camera")[,2]
})
Let’s view a few tree crowns for RGB images. Only plot if we have matching names.
for(x in names(rgb)){
if(!is.null(itcs[[x]])){
plotRGB(rgb[[x]])
plot(itcs[[x]],add=T)
title(x)
}
}
also overlay the two rasters.
for(x in names(rgb)){
if(!is.null(itcs[[x]])){
plotRGB(rgb[[x]])
plot(chms[[x]],add=T,alpha=0.3)
title(x)
}
}